//
//  TT_TabbarViewController.swift
//  BA_MARRY_SWIFT
//
//  Created by 王洋 on 2021/5/10.
//

import UIKit

enum TT_TabbarIndexType {
    case TT_TabbarIndexType_Home
    case TT_TabbarIndexType_Mine
}




class TT_TabbarViewController: UITabBarController, UINavigationControllerDelegate,UITabBarControllerDelegate {

    let homeNav = HomeViewController()
    let mineNav = MineViewController()
    var selectIndex = 0;
    
    override func viewDidLoad() {
        super.viewDidLoad()

        self.tabBar.tintColor = UIColor.white;
        self.tabBar.isTranslucent = false;
        
        addChildControllers();
    }
    
    func addChildControllers() {
        
        configChildVC("首页", norImage: "home_nor", selImage: "home_sel", vc: homeNav);
        configChildVC("我的", norImage: "mine_nor", selImage: "mine_sel", vc: mineNav);
    }
    
    func configChildVC(_ title:String, norImage:String, selImage:String, vc:UIViewController) {
        
        vc.tabBarItem.title = title;
        vc.title = title;
        
        let tabbarNorImage = UIImage(named: norImage)?.withRenderingMode(.alwaysOriginal);
        let tabbarSelImage = UIImage(named: selImage)?.withRenderingMode(.alwaysOriginal);
        vc.tabBarItem = UITabBarItem(title: title, image: tabbarNorImage, selectedImage: tabbarSelImage);
        
        vc.tabBarItem.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.lightGray], for:.normal)
        vc.tabBarItem.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.black], for:.selected)
        addChild(TT_NavigationViewController.init(rootViewController: vc))
    }
}
